<?php

/**
 * 会员注册
 */

namespace app\member\api;

use \app\base\api\BaseApi;

class RegisterApi extends BaseApi {

    /**
     * 注册用户
     */
    public function index() {
        if(!target('member/Member', 'service')->regUser($this->data['username'], $this->data['password'], $this->data['code'])) {
            $this->error(target('Member/Member', 'service')->getError());
        }
        $this->success('帐号注册成功!');
    }

    /**
     * 找回密码
     */
    public function forgot() {
        if(!target('member/Member', 'service')->forgotUser($this->data['username'], $this->data['password'], $this->data['code'])) {
            $this->error(target('Member/Member', 'service')->getError());
        }
        $this->success('密码修改成功!');
    }

    /**
     * 注册协议
     */
    public function agreement() {
        $config = target('member/MemberConfig')->getConfig();
        $this->success('ok', html_out($config['reg_agreement']));
    }

    /**
     * 验证码
     */
    public function verify() {
        if(!target('member/Member', 'service')->getVerify($this->data['receive'], $content)) {
            $this->error(target('member/Member', 'service')->getError());
        }
        $this->success('验证码已发送,请注意查收!');
    }

}